package buyChoco;

public class Solution {
    public int buyChoco(int[] prices, int money) {
        // 贪心 买两块最便宜的巧克力
        int min1 = Integer.MAX_VALUE;
        int min2 = Integer.MAX_VALUE;
        for (int i = 0; i < prices.length; i++) {
            if(min1>prices[i]) {
                min2 = min1;
                min1 = prices[i];
            }else if (min2>prices[i]) {
                min2 = prices[i];
            }
        }
        return (money>=min1+min2)?(money-min1-min2):money;
    }
}
